package com.yc.project.servlet;

import com.google.gson.Gson;
import com.yc.common.util.DBHelper;
import com.yc.project.dao.DishDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

@WebServlet(name = "NewServlet", value = "/new.s")
public class NewServlet extends HttpServlet {
/**查询浏览量最多的6个菜品
 * */
    private DishDao dishDao = new DishDao();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String sql = "select * from gghc_dish ORDER BY time DESC LIMIT 7";
        List<Map<String, Object>> list = DBHelper.selectListMap(sql);
        String json = new Gson().toJson(list);
        response.setContentType("application/json;charset=utf-8");
        response.getWriter().append(json);
    }


}
